package dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import dbutil.DBHelper;

public class ParamsDao {
	private boolean isSuccess;
	
	// 查询所有用户类别
	public List<String> getAllCategorys() throws SQLException {
		String sql = "select t.paraValue from parameters t where t.paraName like '用户类%'";
		PreparedStatement pstmt = null;
		Connection conn = null;
		ResultSet rs = null;
		List<String> list = null;
		try {
			conn = DBHelper.getConnection();
			pstmt = conn.prepareStatement(sql);
			rs = pstmt.executeQuery();
			list = new ArrayList<String>();
			while (rs.next()) {
				list.add(rs.getString(1));
			}
			
			return list;
		} catch (SQLException e) {
			e.printStackTrace();
			return list;
		} finally {
			pstmt.close();
		} 
	}
	
	// 查询所有权限名字
	public List<String> getALLPrivName() throws SQLException {
		String sql = "select priName from privilleges";
		PreparedStatement pstmt = null;
		Connection conn = null;
		ResultSet rs = null;
		List<String> list = null;
		try {
			conn = DBHelper.getConnection();
			pstmt = conn.prepareStatement(sql);
			rs = pstmt.executeQuery();
			list = new ArrayList<String>();
			while (rs.next()) {
				list.add(rs.getString(1));
			}
			
			return list;
		} catch (SQLException e) {
			e.printStackTrace();
			return list;
		} finally {
			pstmt.close();
		} 
	}
	
	public ParamsDao() {
	}

}
